<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dojo Animation</title>

<link rel="stylesheet" type="text/css" href="../theme-remote.css" />
<style type="text/css">
body {
    font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-size: 11px;
}

#debugPanel pre {
    font-family: "Lucida Console", "Courier New", Courier, monospace;
}

div.container {
    border: 0px solid green;
    margin: 10px;
}
</style>

<script type="text/javascript">
var djConfig = {
    isDebug: true,
    parseOnLoad: true,
    locale: "zh",
    extraLocale: ["en"],
    baseUrl: "../script/dojo-1.4.3/dojo/",
    modulePaths: {
        "demo": "../../../script/demo",
        "com": "../../../script/com"
    }
};
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.3/dojo/dojo.xd.js.uncompressed.js"></script>
<script type="text/javascript" src="../script/dojo-require.js"></script>
<script type="text/javascript" src="../script/utils.js"></script>
<script type="text/javascript">
function debug(messages) {
    var msg = demo.utils._getDebugMsg.apply(null, arguments);
    console.debug(msg);

    var msgDiv = dojo.byId("debugPanelContent");
    msgDiv.innerHTML = msg;
}

function append(messages) {
    var msg = demo.utils._getDebugMsg.apply(null, arguments);

    var msgDiv = dojo.byId("debugPanelContent");
    msgDiv.innerHTML += "\n" + msg;
}

function show(id) {
    demo.utils.show(id);
}

function hide(id) {
    demo.utils.hide(id);
}
</script>
<style type="text/css">
@import "../css/rounded-button.css";
@import "../css/rounded-corners.css";

body {
    padding: 10px;
}

</style>
<script type="text/javascript">
dojo.require('dojo.fx.easing');
dojo.require('dojox.fx.scroll');

//////////////////////////////
dojo.ready(function() {
    dojo.byId('version').innerHTML = 'Version ' + dojo.version;

    debug('loaded');

    dojo.subscribe("animation-ended", function(message) {
        console.debug("animation finished!");
    });
});

function runAnimation() {
    var nodeId = "block";
    var anim = dojo.animateProperty({
        node: nodeId,
        // dojo figures out the start value
        properties: { width: { end: 400 } },
        easing: function(n) {
            return (n === 0) ? 0 : Math.pow(2, 10 * (n - 1));
        }
    });

    anim.onEnd = function(node) {
        dojo.publish("animation-ended", []);
    };

    anim.play(500); // delay playing half a second
}

function backToTop() {
    var coords = {x: 0, y: 0};
    var scrollNode = dojo.byId('scrollableBox');
    smoothScroll({coords: coords}, scrollNode);
}

function toTopLink() {
    var node = dojo.byId('toToplink');
    var scrollNode = dojo.byId('scrollableBox');
    smoothScroll({node: node}, scrollNode);
}

function smoothScroll(target, scrollNode) {
    var params = {
        win: scrollNode,
        duration: 500,
        easing: dojo.fx.easing.quintInOut
    };

    if (target.node) {
        params.node = target.node;
    }

    if (target.coords) {
        params.target = target.coords;
    }
    
    var anim = dojox.fx.smoothScroll(params);
    anim.play();
}
//////////////////////////////

</script>
</head>
<body class="tundra">

  <h2 id="version">Unknown Version</h2>

  <div id="main" class="container">

    <div id="titlePanel" dojoType="dijit.TitlePane" title="Panel" style="">
      <div id="resizablePanel" style="position:relative; padding: 10px; border:1px solid black;">

        <!-- Content -->
        <div class="content">
          <div id="block" style="width: 50px; height: 50px; background-color: yellow;">block</div>

          <div id="scrollableBox" style="background-color: cyan; width: 30em; height: 20em; overflow: auto;">
            <p style="width: 100em; height: 60em;"><a href="javascript://" onclick="toTopLink();">jump to link</a></p>
            <div style="width: 20em; height: 10em; margin: 2em 2em 2em 50em;"><a id="toToplink" href="javascript://" onclick="backToTop();">jump to top</a></div>
          </div>
        </div>

        <!-- Resize Handle -->
        <div id="resizeHandle" dojoType="dojox.layout.ResizeHandle" targetId="resizablePanel"></div>
      </div>
    </div>

    <!-- Button Panel -->
    <div dojoType="dojo.dnd.Moveable">
      <div id="buttonPanel" dojoType="dijit.TitlePane" title="Button Panel" style="">
        <!-- Button -->
        <button dojoType="dijit.form.Button" title="Click to show popup dialog" onClick="runAnimation();">Run animation</button>

        <button dojoType="dijit.form.Button" title="Click to show popup dialog" onClick="dijit.byId('dialog').show();">Show Popup</button>

        <!-- DropDown Button -->
        <button dojoType="dijit.form.DropDownButton" title="Click to show TooltipDialog">
          <span>DropDownButton with TooltipDialog</span>
          <!-- TooltipDialog -->
          <div dojoType="dijit.TooltipDialog">
            <label for="name">Name:</label>
            <input dojoType="dijit.form.TextBox" id="name" name="name" />
            <br />
            <div dojoType="dijit.form.Button" type="submit" title="Save">Save</div>
          </div>
        </button>

        <button dojoType="dijit.form.DropDownButton" title="Click to show Menu">
          <span>DropDownButton with Menu</span>
          <!-- Menu -->
          <div dojoType="dijit.Menu" id="menu" style="display: none;">
            <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCut" onClick="alert('Cut!')">Cut</div>
            <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy" onClick="alert('Copy!')">Copy</div>
            <div dojoType="dijit.MenuSeparator"></div>
            <div dojoType="dijit.PopupMenuItem">
              <span>Popup ColorPalette</span>
              <div dojoType="dijit.ColorPalette"></div>
            </div>
          </div>
        </button>
      </div>
    </div>
  </div>

  <!-- Debug Panel -->
  <div id="debugPanel" dojoType="dojox.layout.FloatingPane" title="Console" resizable="true" dockable="true" style="position: absolute; bottom: 20px; right: 20px; width: 500px; height: 150px;">
    <pre id="debugPanelContent"></pre>
  </div>

  <!-- Popup Dialog -->
  <div dojoType="dijit.Dialog" id="dialog" title="Dialog" style="display: none;">
    <button id="okButton" dojoType="dijit.form.Button" title="OK"  onClick="alert('OK!');">OK</button>
    <button id="cancelButton" dojoType="dijit.form.Button" title="Cancel" onClick="dijit.byId('dialog').hide();">Cancel</button>
  </div>

  <!-- Toaster -->
  <div dojoType="dojox.widget.Toaster" id="toaster" positionDirection="br-up" messageTopic="toasterMessageTopic"></div>
</body>
</html>
